﻿using Customer.API.Applcation.Command.ClientCommand;
using Customer.Domain;
using Customer.Infrstructre.ClientManager;
using MediatR;

namespace Customer.API.Applcation.CommandHandlers.ClientCommandHandler
{
    /// <summary>
    /// 客户修改
    /// </summary>
    public class UpdClientCommandHandler:IRequestHandler<UpdClientCommand,int>
    {
        private readonly IClientRepository _clientRep;
        public UpdClientCommandHandler(IClientRepository _clientRep)
        {
            this._clientRep = _clientRep;
        }

        public async Task<int> Handle(UpdClientCommand request, CancellationToken cancellationToken)
        {
            var res = new Client() { ClientId = request.ClientId, ClientCode = request.ClientCode, ClientName = request.ClientName, Cfax = request.Cfax, Landline = request.Landline, Mailbox = request.Mailbox, Cremark = request.Cremark, CusContactId=request.CusContactId, Office_Id = request.Office_Id, User_Id = request.User_Id, AddName = request.AddName, AddTime = request.AddTime, UpdName = request.UpdName, UpdTime = request.UpdTime };
            return await _clientRep.Update(res);
        }
    }
}
